<html ng-app="app">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>抄送接收列表</title>
    <link href="../../build/common/base.css" rel="stylesheet">
    <script type="text/javascript" src="../../build/common/base.js"></script>
    <script type="text/javascript" src="../../build/common/gridList.js"></script>
    <script type="text/javascript" src="../../build/common/easyLayout.js"></script>
</head>
<body class="easy-layout">
<div data-options="region:'center',border:false">
    <!--搜索 .search-panel 必须 -->
    <div class=" search-panel">
        <div class="panel-heading">
            查询条件
            <a 　href="javascript:void(0)" class="pull-right">
                <i class="fa fa-angle-double-up" toggle-collapse="#searchForm"></i>
            </a>
        </div>
        <div class="panel-body">
            <form id="searchForm" class="form-horizontal">
                <div class="form-group" style="margin-right: 0px;">
                    <label class="control-label col-sm-1" for="subject^VLK">标题</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" id="subject^VLK">
                    </div>
                    <label class="control-label col-sm-1" for="node_name^VLK">抄送节点</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" id="node_name^VLK">
                    </div>
                    <label class="control-label col-sm-1" for="read_^VEQ">是否已读</label>
                    <div class="col-sm-2">
                        <select class="form-control" id="read_^VEQ">
                            <option value="">全部</option>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                    <div class="col-sm-3" style="text-align: left;">
                        <button type="button" style="margin-left: 50px" class="btn btn-primary fa-search">查询</button>
                        <button type="button" style="margin-left: 50px" class="btn btn-primary fa-rotate-left">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="btn-group toolbar">
        <a class="btn btn-outline btn-primary fa-comment" href="javascript:void(0)" onclick="updateRead()">标记已读</a>
    </div>
    <table ab-grid data-id-field="id" data-url="/bpm/carbonCopy/receiveList">
        <thead>
        <tr>
            <th data-checkbox="true">序号</th>
            <th data-field="subject">标题</th>
            <th data-field="nodeName">抄送任务</th>
            <th data-field="triggerUserName">抄送人</th>
            <th data-field="read" data-formatter="readFormatter">是否已读</th>
            <th data-field="receiveTime" data-formatter="dateTimeFormatter" data-sort-name="receiveTime">抄送时间</th>
            <th data-field="id" data-formatter="innerHtmlFormatter" data-title="管理">
                <a if="'{formType}' == 'instance'" onclick="read('{id}',{read})" class="fa-columns btn btn-outline btn-primary btn-sm" iview="流程实例表单" openDialog='流程实例表单 【{subject}】' qtip='查看实例详情' url='/bpm/vueForm/instanceDetail.html?id={instId}'></a>
                <a if="'{formType}' == 'task'" onclick="read('{id}',{read})" class="fa-columns btn btn-outline btn-primary btn-sm" openDialog='流程任务表单【{subject}】-【{nodeName}】' qtip='查看任务详情' url='/bpm/vueForm/instanceDetail.html?id={instId}&nodeId={nodeId}'></a>
                <a if='{read}' class="fa-envelope-o btn btn-outline btn-primary btn-sm" openDialog='【{subject}】' dialogConf="'width': 600, 'height':450" qtip='提醒消息内容' url='/bpmplugin/carboncopy/carboncopyReceiveContent.html?recordId={recordId}'></a>
                <a if='!{read}' class="fa-envelope btn btn-outline btn-primary btn-sm" openDialog='【{subject}】' dialogConf="'width': 600, 'height':450" qtip='提醒消息内容' url='/bpmplugin/carboncopy/carboncopyReceiveContent.html?recordId={recordId}'></a>
            </th>
        </tr>
        </thead>
    </table>
</div>
</body>
<script type="text/javascript">
	
	function read(id,hasRead){
		if(hasRead)return;
		 $.post(__ctx + '/bpm/carbonCopy/updateRead', {'id':id}, function (data) {
             var result = eval('(' + data + ')');
             if (result.isOk) {
                     reloadGrid();
             }
         });
	}

    /**
     * 是否已读格式化
     * @param value
     * @param row
     * @param index
     * @returns {string}
     */
    function readFormatter(value, row, index) {
        return '<span class="label label-' + (value ? 'primary' : 'warning') + '">' + (value ? '是' : '否') + '</span>'
    }

    /**
     * 更新已读
     * @returns {boolean}
     */
    function updateRead() {
        if ($(this).hasClass('disabled')) {
            return false;
        }
        var ids = $.getDatagridCheckedId();// 删除的ID数组
        if (ids == null || ids.length < 1) {
            $.Dialog.msg('请选择记录!');
            return false;
        }
        $.Dialog.confirm("温馨提示", '请确认将选中记录更新为已读吗？', function () {
            $.post(__ctx + '/bpm/carbonCopy/updateRead', {'id': ids.join(',')}, function (data) {
                var result = eval('(' + data + ')');
                if (result.isOk) {
                    $.Toast.success('更新成功！', function () {
                        reloadGrid();
                    });
                } else {
                    $.Toast.error(result.msg);
                }
            });
        });
    }
</script>
</html>